home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / util / cli / cliutils_mra.lha / Sources / RequestChoice / Askq.a next >
Encoding:
Text File  |  1999-02-22  |  4.9 KB  |  161 lines

  1. ;
  2. ; $VER: Askq.a V1.0 written by Mauro Panigada
  3. ;
  4. ; Started: 03/14/1996 (month/day/year)
  5. ;
  6. ; (FREEWARE) It needs OS2.0+ (#36)
  7. ;
  8. ; PURPOSE: simple and useful "remake" of dos command 'ask', written
  9. ; in 100% assembly.
  10. ;
  11. ; USAGE: Askq "Text" "Gadget(s)" "Title" "Envar"
  12. ; Type "Askq ?" for a dos-like help.
  13. ;
  14. ; Askq ?
  15. ; TEXT/A,GADGET,TITLE,VAR:
  16. ;
  17. ; Only TEXT is needed. Default gadget is "Yes|No" and title "Request".
  18. ; For gadgets you can specify "gad1|gad2|gad3|..." like EasyRequestArgs,
  19. ; which I use for request. VAR is a name of a var where the result
  20. ; will be stored; if it is not given, result will be stored in an envar
  21. ; named "ENVARC:AskqAnswer" as standard.
  22. ;
  23. ; NOTE: There is also Request by Stefano Reksten and it is copyrighted.
  24. ; Now, my program (freeware, tieh`!) IS NOT COPIED from it. NO PART
  25. ; OF CODE ARE USED OR STOLEN in this my own version.
  26. ;
  27.  
  28.                 incdir  "dh0:progr/assem/include/"
  29.                 include "exec/types.i"
  30.                 include "exec/memory.i"
  31.                 include "exec/libraries.i"
  32.                 include "exec/exec_lib.i"
  33.                 include "dos/dos.i"
  34.                 include "dos/dosextens.i"
  35.                 include "dos/dos_lib.i"
  36.                 include "intuition/intuition.i"
  37.                 include "intuition/intuition_lib.i"
  38.                 include "dos/var.i"
  39.  
  40. LIBVERSION      EQU     36
  41.  
  42. CALL            MACRO
  43.                 jsr     _LVO\1(a6)
  44.                 ENDM
  45.  
  46.  
  47.                 bra.s   start
  48.  
  49.                 dc.b    "$VER: Askq V1.0 (03/14/1996) "
  50.                 dc.b    "written by Mauro Panigada"
  51.                 dc.b    0
  52.                 even
  53.  
  54. start           movea.l 4.w,a6
  55.                 lea     dosname(pc),a1
  56.                 moveq   #LIBVERSION,d0
  57.                 CALL    OpenLibrary
  58.                 move.l  d0,a4
  59.                 tst.l   d0
  60.                 beq     exit
  61.                 lea     intname(pc),a1
  62.                 moveq   #LIBVERSION,d0
  63.                 CALL    OpenLibrary
  64.                 move.l  d0,a5
  65.                 tst.l   d0
  66.                 beq     exit
  67.                 move.l  a4,a6
  68.  
  69.                 move.l  #template,d1
  70.                 move.l  #array,d2
  71.                 moveq   #0,d3
  72.                 CALL    ReadArgs
  73.                 move.l  d0,d7
  74.                 beq     argerror
  75.  
  76. main            lea     array(pc),a0
  77.                 tst.l   (a0)
  78.                 beq     argerror
  79.                 lea     ers(pc),a1
  80.                 move.l  (a0),es_TextFormat(a1)
  81.                 tst.l   4(a0)
  82.                 bne.s   okarg0
  83.                 move.l  #standardgadget,4(a0)
  84. okarg0          move.l  4(a0),es_GadgetFormat(a1)
  85.                 tst.l   8(a0)
  86.                 bne.s   okarg1
  87.                 move.l  #standardtitle,8(a0)
  88. okarg1          move.l  8(a0),es_Title(a1)
  89.                 suba.l  a2,a2
  90.                 suba.l  a3,a3
  91.                 suba.l  a0,a0
  92.                 exg     a5,a6
  93.                 CALL    EasyRequestArgs
  94.                 move.l  d0,d6
  95.                 lea     array(pc),a0
  96.                 tst.l   12(a0)
  97.                 bne.s   okarg2
  98.                 move.l  #varname,12(a0)
  99. okarg2          move.l  d6,stream
  100.                 bsr     convert
  101.                 move.l  12(a0),d1
  102.                 move.l  #cbuf,d2
  103.                 moveq   #-1,d3
  104.                 move.l  #GVF_GLOBAL_ONLY,d4
  105.                 exg     a5,a6
  106.                 CALL    SetVar
  107.                         ; ignore possible but rare (I hope) errors...
  108. exit0           move.l  d7,d1
  109.                 beq.s   exit
  110.                 CALL    FreeArgs
  111.  
  112. exit            move.l  a4,a1
  113.                 movea.l 4.w,a6
  114.                 CALL    CloseLibrary
  115.                 move.l  a5,a1
  116.                 CALL    CloseLibrary
  117.                 move.l  d6,d0
  118.                 rts
  119.  
  120. argerror        move.l  #helpscr,d1
  121.                 CALL    PutStr
  122.                 bra.s   exit0
  123.  
  124. convert         movem.l a0/a6,-(sp)
  125.                 movea.l 4.w,a6
  126.                 lea     formatstr(pc),a0
  127.                 lea     stream(pc),a1
  128.                 lea     proc(pc),a2
  129.                 lea     cbuf(pc),a3
  130.                 CALL    RawDoFmt
  131.                 movem.l (sp)+,a0/a6
  132.                 rts
  133. proc            move.b  d0,(a3)+
  134.                 rts
  135.  
  136. ;=========================================================================
  137. dosname         dc.b    "dos.library",0
  138.                 even
  139. intname         dc.b    "intuition.library",0
  140.                 even
  141. ers             dc.l    EasyStruct_SIZEOF
  142.                 dc.l    0
  143.                 dc.l    0,0,0
  144. standardgadget  dc.b    "Yes|No",0
  145.                 even
  146. standardtitle   dc.b    "Request",0
  147.                 even
  148. varname         dc.b    "ENVARC:AskqAnswer",0
  149.                 even
  150. template        dc.b    "TEXT/A,GADGET,TITLE,VAR",0
  151.                 even
  152. formatstr       dc.b    "%ld",0
  153. array           dc.l    0,0,0,0
  154. cbuf            dc.l    0
  155. stream          dc.l    0
  156. helpscr         dc.b    "Askq V1.0 by Mauro Panigada",10
  157.                 dc.b    "USAGE: Askq TEXT [GADGETS] [TITLE] [VAR]",10
  158.                 dc.b    0
  159.  
  160.                 END
  161.